<!-- 我的团队 -->
<template>
  <div class="myteam_contaniner">
    <van-pull-refresh v-model="isLoading" @refresh="onRefresh" style="height:calc(100vh - 46px);overflow: auto;">
      <van-list v-model="loading" :finished="finished" finished-text="我是有底线的" @load="onLoad" :immediate-check="false" :offset="10">
        <van-tabs v-model="active" @click="getMyTeam" animated>
          <van-tab name="my">
            <div slot="title">
              我的下级
              <!-- <van-tag round  color="#e8bb57" type="danger" size="medium">120</van-tag> -->
            </div>
            <div class="list" v-for="item in getList" :key="item.id">
              <van-row>
                <van-col span="15" class="dsf1">
                  <van-col span="24">
                    <div class="dsf">
                      <img v-if="item.image" :src="item.image" alt="">
                      <img v-else src="@/assets/images/mobileLogo.jpg" alt="">
                      <span class="red">{{item.mobile = item.mobile.substring(0,3) + '****' + item.mobile.substring(7,11)}}</span>
                      <van-tag mark type="success">{{item.levelName}}</van-tag>
                    </div>
                    <div class="dsf">
                      <p class="gray">{{common.formatDate(item.registerTime)}}</p>
                    </div>
                  </van-col>
                </van-col>
                <van-col span="9" class="dsf1 tar">
                  <div>
                    <p>他的团队:<span class="red">{{item.subMemberCount}}</span></p>
                    <p>投资(USDT):<span class="red">{{item.paymentAmt}}</span></p>
                    <p>获得贡献分:<span class="red">{{item.devoteMark}}</span></p>
                  </div>
                </van-col>
              </van-row>
            </div>
          </van-tab>
          <van-tab name="all">
            <div slot="title">
              我的团队
              <!-- <van-tag round  color="#e8bb57" type="danger" size="medium">1111</van-tag> -->
            </div>
            <div class="list" v-for="item in getList" :key="item.id">
              <van-row>
                <van-col span="15" class="dsf1">
                  <van-col span="24">
                    <div class="dsf">
                      <img :src="item.image" alt="">
                      <span class="red">{{item.mobile = item.mobile.substring(0,3) + '****' + item.mobile.substring(7,11)}}</span>
                      <van-tag mark type="success">{{item.levelName}}</van-tag>
                    </div>
                    <div class="dsf">
                      <p class="gray">{{common.formatDate(item.registerTime)}}</p>
                    </div>
                  </van-col>
                </van-col>
                <van-col span="9" class="dsf1 tar">
                  <div>
                    <p>他的团队:<span class="red">{{item.subMemberCount}}</span></p>
                    <p>投资(USDT):<span class="red">{{item.paymentAmt}}</span></p>
                    <p>获得贡献分:<span class="red">{{item.devoteMark}}</span></p>
                  </div>
                </van-col>
              </van-row>
            </div>
          </van-tab>
        </van-tabs>
      </van-list>
    </van-pull-refresh>
  </div>
</template>

<script>
export default {
  data () {
    return {
      active: 'my',
      mobile: '15859526995',
      data: {
        pageSize: 10,
        currentPage: 1,
      },
      isLoading: false,
      finished: false,  //是否加载完所有数据
      loading: false,  //是否加载完所有数据
      getList: [],
    };
  },
  methods: {
    onLoad () {      //上拉加载
      console.log(44444)
      setTimeout(() => {
        this.getMyTeam()
        this.loading = true
        this.data.currentPage++
      }, 500)
    },
    onRefresh () {
      setTimeout(() => {
        this.isLoading = false;
        this.loading = false
        this.finished = false
        this.data.currentPage = 1;
        this.getList = []
        this.getMyTeam()
        this.$toast('刷新成功');
      }, 500);
    },
    //获取我的团队列表
    async getMyTeam () {
      let url = this.active == 'my' ? '/member/queryMyMemberPage' : '/member/queryMyMemberAllPage'
      let result = await this.request.mobileRequest('POST', url, this.data)
      if (result.code == 200) {
        this.loading = false
        if (this.data.currentPage === 1) {
          this.getList = result.data.datas
          console.log(2222)
        } else {
          if (result.data.datas != '' && this.data.currentPage > 1) {
            this.getList = this.getList.concat(result.data.datas)
            console.log(3333)
          }
        }
        if (result.data.datas.length < this.data.pageSize) {
          this.finished = true
        }
      } else {
        this.$notify({ type: 'warning', message: result.msg });
      }
    }
  },
  mounted () {
    this.getMyTeam();
  }
};
</script>

<style scoped>
.van-tab span {
  display: inline-block;
  padding-left: 0.2rem;
}
.dsf {
  height: 0.9rem;
  display: flex;
  align-items: center;
}
.dsf1 {
  height: 1.8rem;
  display: flex;
  align-items: center;
}
.list {
  padding: 0.2rem;
  background: #fff;
  border-bottom: 0.02rem solid #d9d9d9;
}
.van-col img {
  width: 0.8rem;
  height: 0.8rem;
  border-radius: 50%;
}
.van-col span {
  margin-left: 0.15rem !important;
  font-size: 0.32rem;
}
.tar p {
  text-align: left;
  font-size: 0.3rem;
  line-height: 0.5rem;
}
</style>
